#include "World.h"


World::World(Environment* env) {
	environment = env;
	

}

void World::init() {
	entities = new EntHandler(this);

	// TODO: separate this
	Ent* e = new EntCube;
	entities->add(e);
	e->setPosition(vect(0, 256, 0));

	pacman = new EntPacman;
	entities->add(pacman);
	pacman->setPosition(vect(-64, 128, 0));

	ghost1 = new EntGhost(vect(1,0,0)); // red
	entities->add(ghost1);
	ghost1->setPosition(vect(-32, 128, 0));
	ghost2 = new EntGhost(vect(1,.5,.5)); // pink
	entities->add(ghost2);
	ghost2->setPosition(vect(0, 128, 0)); 
	ghost3 = new EntGhost(vect(1,.5,0)); // orange
	entities->add(ghost3);
	ghost3->setPosition(vect(32, 128, 0));
	ghost4 = new EntGhost(vect(0,1,1)); // cyan
	entities->add(ghost4);
	ghost4->setPosition(vect(64, 128, 0));

	ghost1->setName("ghost1");
	ghost2->setName("ghost2");
	ghost3->setName("ghost3");
	ghost4->setName("ghost4");
	pacman->setName("pacman");
}

World::~World() {
	delete entities;
	delete environment;
}

Environment* World::getEnvironment() {
	return environment;
}

EntHandler* World::getEntities() {
	return entities;
}

void World::think() {
	environment->think();
	entities->thinkAll();	
}

void World::draw() {
	environment->draw();
	entities->drawAll();	

}
